import requests
# rp=requests.get(url="http://www.baidu.com")
sess=requests.session()

rp=sess.request("get",url="http://www.baidu.com")
#普通的GET类型接口
def gettest():
    params={"id":1}
    rp=sess.request("get","http://192.168.1.84:8080/pinter/com/getSku",params=params)
    print(rp.text)
#参数为k=v的POST接口
def posttest():
    data = {'userName':"admin",'password':"123456"}
    rp = sess.request("post","http://192.168.1.84:8080/pinter/com/login",data=data)
    print(rp.text)
#参数为json的POST接口
def post_json_test():
    json = {"userName": "test", "password": "1234", "gender": 1, "phoneNum": "110", "email": "beihe@163.com","address": "Beijing"}
    rp = sess.request("post","http://192.168.1.84:8080/pinter/com/register" ,json=json)
    print(rp.text)
#参数为k=json的POST接口
def key_posttest():
    data = {"param":{"skuId":123,"num":10}}
    rp = sess.request("post", "http://192.168.1.84:8080/pinter/com/buy", data=data)
    print(rp.text)
#返回json数组的GET接口
def json_gettest():
    params={"genderType":0}
    rp=sess.request("get","http://192.168.1.84:8080/pinter/com/userList",params=params)
    print(rp.text)
if __name__=="__main__":
    post_json_test()
    posttest()
    gettest()
    key_posttest()
    json_gettest()